/**
 * \file Thread_Linux.h
 * \brief Task definition class for Linux platforms
 * \author Edouard ROGE
 * \date 29 august 2012
 */

#ifndef _THREAD_LINUX_
#define _THREAD_LINUX_

#include "Core/Error/Error.h"
#include "Core/Memory/HeapObject.h"

/**
 * \class Thread
 * \brief Virtual class. Inherit from it to perform computations on another thread
 */
class Thread : public HeapObject
{
public:

	/**
	 * \fn Thread();
	 * \brief Default constructor
	 */
	Thread();

	/**
	 * \fn virtual ~Thread();
	 * \brief Destructor
	 */
	virtual ~Thread();

	/**
	 * \fn uint32 GetThreadId() const;
	 * \return the current thread id
	 * \brief get the current thread id
	 */
	uint32 GetThreadId() const;

	/**
	 * \fn virtual void Start();
	 * \brief Start the task
	 */
	virtual void Start();

	/**
	 * \fn virtual void Run()=0;
	 * \brief overload this function. this function is executed on another thread
	 */
	virtual void Run()=0;

private:

	/**
	 * \fn static void *RunTask(void * _pContext);
	 * \brief function to start the thread after its register in the TaskManager
	 */
	static void * RunTask(void * _pContext);

	/** thread id */
	pthread_t m_thread;

	/** parent thread id */
	pthread_t m_parentThread;

	friend class ThreadManager;

	friend class ThreadLauncher;
};

#endif // _Thread_LINUX_

